<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" >
    <meta http-equiv="X-UA-Compatible" content="IE=11,IE=10,IE=9,IE=8" >
    <meta name="baidu-site-verification" content="dIcXMeY8Ya" />
    
    <title>基于XML的DI-03 | 即将拥有人鱼线丶</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" >
    <meta name="keywords" content="FutaoSmile, 前端, Web, 付韬, 个人博客" >
    <meta name="description" content="付韬FutaoSmile" >

    
    <link rel="alternative" href="/atom.xml" title="即将拥有人鱼线丶" type="application/atom+xml" >
    
    
    <link rel="shortcut icon" href="/coder957/coder957/favicon.ico" >
    
    <link rel="stylesheet" href="/coder957/css/style.css">
    <!--[if lt IE 9]>
    <script src="/coder957/js/html5.js"></script>
    <![endif]-->
    
<script>
    var _hmt = _hmt || [];
    (function() {
        var hm = document.createElement("script");
        hm.src = "//hm.baidu.com/hm.js?fd459238242776d173cdc64918fb32f2";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>


</head>

<body class="home">
    <!--[if lt IE 9]>
    <div class="browsehappy">
        当前网页 <strong>不支持</strong>
        你正在使用的浏览器. 为了正常的访问, 请 <a href="http://browsehappy.com/">升级你的浏览器</a>.
    </div>
    <![endif]-->

    <!-- 博客头部 -->
    <header class="header">
    <section class="container header-main">
        <div class="logo">
            <a href="/coder957/">
                <div class="cover">
                    <span class="name">即将拥有人鱼线丶</span>
                    <span class="description">FutaoSmile</span>
                </div>
            </a>
        </div>
        <div class="dropnav icon-paragraph-justify" id="JELON__btnDropNav"></div>
        <ul class="menu hidden" id="JELON__menu">
            
                <li rel="/coder957/2017/10/12/基于XMl的DI-03/index.html" class="item ">
                    <a href="/coder957/" title="首页" class="icon-home">&nbsp;首页</a>
                </li>
                
                <li rel="/coder957/2017/10/12/基于XMl的DI-03/index.html" class="item ">
                    <a href="/coder957/lab/" title="实验室" class="icon-lab">&nbsp;实验室</a>
                </li>
                
                <li rel="/coder957/2017/10/12/基于XMl的DI-03/index.html" class="item ">
                    <a href="/coder957/about/" title="关于" class="icon-about">&nbsp;关于</a>
                </li>
                
                <li rel="/coder957/2017/10/12/基于XMl的DI-03/index.html" class="item ">
                    <a href="/coder957/comment/" title="留言" class="icon-comment">&nbsp;留言</a>
                </li>
                
        </ul>
        <div class="profile clearfix">
            <div class="feeds fl">
                
                    
                        <p class="links">
                            
                                <a href="https://github.com/FutaoSmile" target="_blank">
                                    Github
                                </a>
                                |
                                    
                                        
                                <a href="http://www.jianshu.com/u/9e2e579df7dd" target="_blank">
                                    简书
                                </a>
                                
                                        
                        </p>
                        <p class="sns">
                            
                                <a href="http://weibo.com/u/2379076265?refer_flag=1001030001_&amp;nick=FutaoSmile%E4%B8%B6" class="sinaweibo" target="_blank"><b>■</b> 新浪微博</a>
                                
                                <a href="https://gitee.com/FutaoSmile" class="qqweibo" target="_blank"><b>■</b> 码云</a>
                                
                                    <!-- <a href="javascript: void(0);" class="wechat">
                        <b>■</b>
                        公众号
                        <span class="popover">
                            <img src="/coder957/img/wechat_mp.jpg" width="120" height="120" alt="我的微信订阅号">
                            <i class="arrow"></i>
                        </span>
                    </a> -->
                        </p>
                        
            </div>
            <div class="avatar fr">
                <img src="/coder957/img/head.png" alt="avatar" title="Jelon">
            </div>
        </div>
    </section>
</header>

    <!-- 博客正文 -->
    <div class="container body clearfix">
        <section class="content">
            <div class="content-main widget">
                <!-- 文章页 -->
<!-- 文章 -->
<article class="post article">
    <header class="text-center">
        <h3 class="post-title"><span>基于XML的DI-03</span></h3>
    </header>
    <p class="post-meta text-center">
        FutaoSmile丶 发表于
            <time datetime="2017-10-12T07:03:30.910Z">2017-10-12</time>
    </p>
    <div class="post-content">
        <p>des…</p>
<blockquote>
<p>基于XMl的DI</p>
<ol>
<li>匿名Bean</li>
<li>匿名内部Bean</li>
<li>同类抽象Bean</li>
<li>异类抽象Bean</li>
<li>多个配置文件-平行关系</li>
<li>多个配置文件-包含关系</li>
</ol>
</blockquote>
<a id="more"></a>
<p><a href="http://www.cnblogs.com/nerxious/archive/2013/01/25/2876489.html" target="_blank" rel="external">Java中的匿名内部类</a></p>
<h2 id="匿名Bean"><a href="#匿名Bean" class="headerlink" title="匿名Bean"></a>匿名Bean</h2><blockquote>
<p>没有id，但是可以通过autowire=”byType”找到。<br>即：不能通过getBean()得到这个Bean<br><strong>School类</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div></pre></td><td class="code"><pre><div class="line">package Part03.InnerNonameBean;</div><div class="line"></div><div class="line">/**</div><div class="line"> * Created by futao on 2017/10/12.</div><div class="line"> */</div><div class="line">public class School &#123;</div><div class="line">    private String sname;</div><div class="line"></div><div class="line">    public String getSname() &#123;</div><div class="line">        return sname;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setSname(String sname) &#123;</div><div class="line">        this.sname = sname;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    @Override</div><div class="line">    public String toString() &#123;</div><div class="line">        return &quot;School&#123;&quot; +</div><div class="line">                &quot;sname=&apos;&quot; + sname + &apos;\&apos;&apos; +</div><div class="line">                &apos;&#125;&apos;;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
</blockquote>
<p><strong>Student类</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div></pre></td><td class="code"><pre><div class="line">package Part03.InnerNonameBean;</div><div class="line"></div><div class="line">/**</div><div class="line"> * Created by futao on 2017/10/12.</div><div class="line"> */</div><div class="line">public class Student &#123;</div><div class="line">    private String sname;</div><div class="line">    private int age;</div><div class="line">    private School school;</div><div class="line"></div><div class="line">    public String getSname() &#123;</div><div class="line">        return sname;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setSname(String sname) &#123;</div><div class="line">        this.sname = sname;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public int getAge() &#123;</div><div class="line">        return age;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setAge(int age) &#123;</div><div class="line">        this.age = age;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public School getSchool() &#123;</div><div class="line">        return school;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setSchool(School school) &#123;</div><div class="line">        this.school = school;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    @Override</div><div class="line">    public String toString() &#123;</div><div class="line">        return &quot;Student&#123;&quot; +</div><div class="line">                &quot;sname=&apos;&quot; + sname + &apos;\&apos;&apos; +</div><div class="line">                &quot;, age=&quot; + age +</div><div class="line">                &quot;, school=&quot; + school +</div><div class="line">                &apos;&#125;&apos;;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><strong>配置文件</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line">&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;</div><div class="line">       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</div><div class="line">       xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&quot;&gt;</div><div class="line">    &lt;!--这个bean没有id属性，所以是匿名的--&gt;</div><div class="line">    &lt;bean class=&quot;Part03.InnerNonameBean.School&quot;&gt;</div><div class="line">        &lt;property name=&quot;sname&quot; value=&quot;Ecjtu&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">    &lt;bean id=&quot;student&quot; class=&quot;Part03.InnerNonameBean.Student&quot; autowire=&quot;byType&quot;&gt;</div><div class="line">        &lt;property name=&quot;sname&quot; value=&quot;小王&quot;/&gt;</div><div class="line">        &lt;property name=&quot;age&quot; value=&quot;18&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">&lt;/beans&gt;</div></pre></td></tr></table></figure></p>
<p><strong>测试</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">/**</div><div class="line">   * 匿名类/匿名内部类</div><div class="line">   */</div><div class="line">  @Test</div><div class="line">  fun test4NonameBean() &#123;</div><div class="line">      val classPathXmlApplicationContext = ClassPathXmlApplicationContext(&quot;applicationContextInnerNonameBean.xml&quot;)</div><div class="line">      val student = classPathXmlApplicationContext.getBean(&quot;student&quot;) as Part03.InnerNonameBean.Student</div><div class="line">      println(GsonBuilder().serializeNulls().setPrettyPrinting().create().toJson(student))</div><div class="line">  &#125;</div></pre></td></tr></table></figure></p>
<p><strong>结果</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">&#123;</div><div class="line">  &quot;sname&quot;: &quot;小王&quot;,</div><div class="line">  &quot;age&quot;: 18,</div><div class="line">  &quot;school&quot;: &#123;</div><div class="line">    &quot;sname&quot;: &quot;Ecjtu&quot;</div><div class="line">  &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h2 id="匿名内部Bean"><a href="#匿名内部Bean" class="headerlink" title="匿名内部Bean"></a>匿名内部Bean</h2><p>特点：<br>1.匿名的，所以该bean在配置文件中没有id属性，也就不能通过getBean()得到<br>2.内部的，该bean被其他bean的属性标签包裹，所以也无法通过autowire=”byType”得到。所以这个bean只能被这个包裹他的bean所使用</p>
<p><strong>修改配置文件</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line">&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;</div><div class="line">       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</div><div class="line">       xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&quot;&gt;</div><div class="line"></div><div class="line">    &lt;bean id=&quot;student&quot; class=&quot;Part03.InnerNonameBean.Student&quot;&gt;</div><div class="line">        &lt;property name=&quot;sname&quot; value=&quot;小王&quot;/&gt;</div><div class="line">        &lt;property name=&quot;age&quot; value=&quot;18&quot;/&gt;</div><div class="line">        &lt;property name=&quot;school&quot;&gt;</div><div class="line">            &lt;!--1.这个bean没有id属性，所以是匿名的--&gt;</div><div class="line">            &lt;!--2.这个bean是在student的school属性中，所以是内部的--&gt;</div><div class="line">            &lt;bean class=&quot;Part03.InnerNonameBean.School&quot;&gt;</div><div class="line">                &lt;property name=&quot;sname&quot; value=&quot;Ecjtu&quot;/&gt;</div><div class="line">            &lt;/bean&gt;</div><div class="line">        &lt;/property&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">&lt;/beans&gt;</div></pre></td></tr></table></figure></p>
<h2 id="同类抽象Bean"><a href="#同类抽象Bean" class="headerlink" title="同类抽象Bean"></a>同类抽象Bean</h2><p><code>abstract=&quot;true&quot;</code><br><strong>Student类</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div></pre></td><td class="code"><pre><div class="line">package Part03.SameAbstractBean;</div><div class="line"></div><div class="line">/**</div><div class="line"> * Created by futao on 2017/10/12.</div><div class="line"> */</div><div class="line">public class Student &#123;</div><div class="line">    private String sname;</div><div class="line">    private int age;</div><div class="line">    private String school;</div><div class="line">    private String department;</div><div class="line"></div><div class="line">    public String getSname() &#123;</div><div class="line">        return sname;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setSname(String sname) &#123;</div><div class="line">        this.sname = sname;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public int getAge() &#123;</div><div class="line">        return age;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setAge(int age) &#123;</div><div class="line">        this.age = age;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public String getSchool() &#123;</div><div class="line">        return school;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setSchool(String school) &#123;</div><div class="line">        this.school = school;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public String getDepartment() &#123;</div><div class="line">        return department;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setDepartment(String department) &#123;</div><div class="line">        this.department = department;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    @Override</div><div class="line">    public String toString() &#123;</div><div class="line">        return &quot;Student&#123;&quot; +</div><div class="line">                &quot;sname=&apos;&quot; + sname + &apos;\&apos;&apos; +</div><div class="line">                &quot;, age=&quot; + age +</div><div class="line">                &quot;, school=&apos;&quot; + school + &apos;\&apos;&apos; +</div><div class="line">                &quot;, department=&apos;&quot; + department + &apos;\&apos;&apos; +</div><div class="line">                &apos;&#125;&apos;;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><strong>配置文件</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line">&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;</div><div class="line">       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</div><div class="line">       xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&quot;&gt;</div><div class="line">    &lt;!--传统方式，代码大量冗余--&gt;</div><div class="line">    &lt;bean id=&quot;student1&quot; class=&quot;Part03.SameAbstractBean.Student&quot;&gt;</div><div class="line">        &lt;property name=&quot;sname&quot; value=&quot;张三&quot;/&gt;</div><div class="line">        &lt;property name=&quot;age&quot; value=&quot;18&quot;/&gt;</div><div class="line">        &lt;property name=&quot;school&quot; value=&quot;Ecjtu&quot;/&gt;</div><div class="line">        &lt;property name=&quot;department&quot; value=&quot;计算机学院&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">    &lt;bean id=&quot;student2&quot; class=&quot;Part03.SameAbstractBean.Student&quot;&gt;</div><div class="line">        &lt;property name=&quot;sname&quot; value=&quot;李四&quot;/&gt;</div><div class="line">        &lt;property name=&quot;age&quot; value=&quot;38&quot;/&gt;</div><div class="line">        &lt;property name=&quot;school&quot; value=&quot;NCDX&quot;/&gt;</div><div class="line">        &lt;property name=&quot;department&quot; value=&quot;软件学院&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">    &lt;bean id=&quot;student3&quot; class=&quot;Part03.SameAbstractBean.Student&quot;&gt;</div><div class="line">        &lt;property name=&quot;sname&quot; value=&quot;王五&quot;/&gt;</div><div class="line">        &lt;property name=&quot;age&quot; value=&quot;68&quot;/&gt;</div><div class="line">        &lt;property name=&quot;school&quot; value=&quot;SHJD&quot;/&gt;</div><div class="line">        &lt;property name=&quot;department&quot; value=&quot;计算机科学学院&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">    &lt;!--同类抽象Bean，抽象的 abstract=&quot;true&quot;--&gt;</div><div class="line">    &lt;bean id=&quot;baseStudent&quot; class=&quot;Part03.SameAbstractBean.Student&quot; abstract=&quot;true&quot;&gt;</div><div class="line">        &lt;property name=&quot;school&quot; value=&quot;Ecjtu&quot;/&gt;</div><div class="line">        &lt;property name=&quot;department&quot; value=&quot;计算机科学&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">    &lt;bean id=&quot;student1-1&quot; parent=&quot;baseStudent&quot;&gt;</div><div class="line">        &lt;property name=&quot;age&quot; value=&quot;100&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">    &lt;bean id=&quot;student1-2&quot; parent=&quot;baseStudent&quot;&gt;</div><div class="line">        &lt;property name=&quot;school&quot; value=&quot;NCDX&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">&lt;/beans&gt;</div></pre></td></tr></table></figure></p>
<p><strong>测试</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div></pre></td><td class="code"><pre><div class="line"> /**</div><div class="line">     * 同类抽象Bean</div><div class="line">     */</div><div class="line">    @Test</div><div class="line">    fun test4SameAbstractBean() &#123;</div><div class="line">        val classPathXmlApplicationContext = ClassPathXmlApplicationContext(&quot;applicationContextSameAbstractBean.xml&quot;)</div><div class="line">//        val student1 = classPathXmlApplicationContext.getBean(&quot;student1&quot;) as Part03.SameAbstractBean.Student</div><div class="line">//        println(GsonBuilder().serializeNulls().setPrettyPrinting().create().toJson(student1))</div><div class="line">//        val student2 = classPathXmlApplicationContext.getBean(&quot;student2&quot;) as Part03.SameAbstractBean.Student</div><div class="line">//        println(GsonBuilder().serializeNulls().setPrettyPrinting().create().toJson(student2))</div><div class="line">//        val student3 = classPathXmlApplicationContext.getBean(&quot;student3&quot;) as Part03.SameAbstractBean.Student</div><div class="line">//        println(GsonBuilder().serializeNulls().setPrettyPrinting().create().toJson(student3))</div><div class="line"></div><div class="line">        val baseStudent = classPathXmlApplicationContext.getBean(&quot;baseStudent&quot;) as Part03.SameAbstractBean.Student</div><div class="line">        println(GsonBuilder().serializeNulls().setPrettyPrinting().create().toJson(baseStudent))</div><div class="line">        val student11 = classPathXmlApplicationContext.getBean(&quot;student1-1&quot;) as Part03.SameAbstractBean.Student</div><div class="line">        println(GsonBuilder().serializeNulls().setPrettyPrinting().create().toJson(student11))</div><div class="line">        val student12 = classPathXmlApplicationContext.getBean(&quot;student1-2&quot;) as Part03.SameAbstractBean.Student</div><div class="line">        println(GsonBuilder().serializeNulls().setPrettyPrinting().create().toJson(student12))</div><div class="line"></div><div class="line"></div><div class="line">    &#125;</div></pre></td></tr></table></figure></p>
<p><strong>结果</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line">&#123;</div><div class="line">  &quot;sname&quot;: null,</div><div class="line">  &quot;age&quot;: 0,</div><div class="line">  &quot;school&quot;: &quot;Ecjtu&quot;,</div><div class="line">  &quot;department&quot;: &quot;计算机科学&quot;</div><div class="line">&#125;</div><div class="line">&#123;</div><div class="line">  &quot;sname&quot;: null,</div><div class="line">  &quot;age&quot;: 100,</div><div class="line">  &quot;school&quot;: &quot;Ecjtu&quot;,</div><div class="line">  &quot;department&quot;: &quot;计算机科学&quot;</div><div class="line">&#125;</div><div class="line">&#123;</div><div class="line">  &quot;sname&quot;: null,</div><div class="line">  &quot;age&quot;: 0,</div><div class="line">  &quot;school&quot;: &quot;NCDX&quot;,</div><div class="line">  &quot;department&quot;: &quot;计算机科学&quot;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h2 id="异类抽象Bean"><a href="#异类抽象Bean" class="headerlink" title="异类抽象Bean"></a>异类抽象Bean</h2><blockquote>
<p>将一部分bean的某些相同的属性拿出来，组成一个bean，这个bean没有class，需要标注<code>abstract=&quot;true&quot;</code></p>
</blockquote>
<p><strong>Student类</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div></pre></td><td class="code"><pre><div class="line">package Part03.DiffAbstractBean;</div><div class="line"></div><div class="line">/**</div><div class="line"> * Created by futao on 2017/10/12.</div><div class="line"> */</div><div class="line">public class Student &#123;</div><div class="line">    private String name;</div><div class="line">    private int age;</div><div class="line">    private String school;</div><div class="line">    private String department;</div><div class="line"></div><div class="line">    public String getName() &#123;</div><div class="line">        return name;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setName(String name) &#123;</div><div class="line">        this.name = name;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public int getAge() &#123;</div><div class="line">        return age;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setAge(int age) &#123;</div><div class="line">        this.age = age;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public String getSchool() &#123;</div><div class="line">        return school;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setSchool(String school) &#123;</div><div class="line">        this.school = school;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public String getDepartment() &#123;</div><div class="line">        return department;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setDepartment(String department) &#123;</div><div class="line">        this.department = department;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    @Override</div><div class="line">    public String toString() &#123;</div><div class="line">        return &quot;Student&#123;&quot; +</div><div class="line">                &quot;name=&apos;&quot; + name + &apos;\&apos;&apos; +</div><div class="line">                &quot;, age=&quot; + age +</div><div class="line">                &quot;, school=&apos;&quot; + school + &apos;\&apos;&apos; +</div><div class="line">                &quot;, department=&apos;&quot; + department + &apos;\&apos;&apos; +</div><div class="line">                &apos;&#125;&apos;;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><strong>Teacher类</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div></pre></td><td class="code"><pre><div class="line">package Part03.DiffAbstractBean;</div><div class="line"></div><div class="line">/**</div><div class="line"> * Created by futao on 2017/10/12.</div><div class="line"> */</div><div class="line">public class Teacher &#123;</div><div class="line">    private String name;</div><div class="line">    private int wordAge;</div><div class="line">    private String school;</div><div class="line">    private String department;</div><div class="line"></div><div class="line">    public String getName() &#123;</div><div class="line">        return name;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setName(String name) &#123;</div><div class="line">        this.name = name;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public int getWordAge() &#123;</div><div class="line">        return wordAge;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setWordAge(int wordAge) &#123;</div><div class="line">        this.wordAge = wordAge;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public String getSchool() &#123;</div><div class="line">        return school;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setSchool(String school) &#123;</div><div class="line">        this.school = school;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public String getDepartment() &#123;</div><div class="line">        return department;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setDepartment(String department) &#123;</div><div class="line">        this.department = department;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    @Override</div><div class="line">    public String toString() &#123;</div><div class="line">        return &quot;Teacher&#123;&quot; +</div><div class="line">                &quot;name=&apos;&quot; + name + &apos;\&apos;&apos; +</div><div class="line">                &quot;, wordAge=&quot; + wordAge +</div><div class="line">                &quot;, school=&apos;&quot; + school + &apos;\&apos;&apos; +</div><div class="line">                &quot;, department=&apos;&quot; + department + &apos;\&apos;&apos; +</div><div class="line">                &apos;&#125;&apos;;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><strong>配置文件</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line">&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;</div><div class="line">       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</div><div class="line">       xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&quot;&gt;</div><div class="line">    &lt;!--异类抽象Bean--&gt;</div><div class="line">    &lt;bean id=&quot;baseBean&quot; abstract=&quot;true&quot;&gt;</div><div class="line">        &lt;property name=&quot;school&quot; value=&quot;华东交通大学111&quot;/&gt;</div><div class="line">        &lt;property name=&quot;department&quot; value=&quot;计算机科学&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">    &lt;bean id=&quot;student&quot; class=&quot;Part03.DiffAbstractBean.Student&quot; parent=&quot;baseBean&quot;&gt;</div><div class="line">        &lt;property name=&quot;name&quot; value=&quot;张三&quot;/&gt;</div><div class="line">        &lt;property name=&quot;age&quot; value=&quot;23&quot;/&gt;</div><div class="line">        &lt;!--&lt;property name=&quot;school&quot; value=&quot;Ecjtu&quot;/&gt;--&gt;</div><div class="line">        &lt;!--&lt;property name=&quot;department&quot; value=&quot;软件学院&quot;/&gt;--&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">    &lt;bean id=&quot;teacher&quot; class=&quot;Part03.DiffAbstractBean.Teacher&quot; parent=&quot;baseBean&quot;&gt;</div><div class="line">        &lt;property name=&quot;name&quot; value=&quot;老王&quot;/&gt;</div><div class="line">        &lt;property name=&quot;wordAge&quot; value=&quot;18&quot;/&gt;</div><div class="line">        &lt;!--&lt;property name=&quot;department&quot; value=&quot;软件学院&quot;/&gt;--&gt;</div><div class="line">        &lt;!--&lt;property name=&quot;school&quot; value=&quot;Ecjtu&quot;/&gt;--&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">&lt;/beans&gt;</div></pre></td></tr></table></figure></p>
<p><strong>测试</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">/**</div><div class="line">     * 异类抽象Bean</div><div class="line">     */</div><div class="line">    @Test</div><div class="line">    fun test4DiffAbstractBean() &#123;</div><div class="line">        val classPathXmlApplicationContext = ClassPathXmlApplicationContext(&quot;applicationContextDiffAbstractBean.xml&quot;)</div><div class="line">        val student = classPathXmlApplicationContext.getBean(&quot;student&quot;) as Part03.DiffAbstractBean.Student</div><div class="line">        println(GsonBuilder().serializeNulls().setPrettyPrinting().create().toJson(student))</div><div class="line"></div><div class="line">        val teacher = classPathXmlApplicationContext.getBean(&quot;teacher&quot;) as Teacher</div><div class="line">        println(GsonBuilder().serializeNulls().setPrettyPrinting().create().toJson(teacher))</div><div class="line">    &#125;</div></pre></td></tr></table></figure></p>
<p><strong>结果</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">&#123;</div><div class="line">  &quot;name&quot;: &quot;张三&quot;,</div><div class="line">  &quot;age&quot;: 23,</div><div class="line">  &quot;school&quot;: &quot;华东交通大学111&quot;,</div><div class="line">  &quot;department&quot;: &quot;计算机科学&quot;</div><div class="line">&#125;</div><div class="line">&#123;</div><div class="line">  &quot;name&quot;: &quot;老王&quot;,</div><div class="line">  &quot;wordAge&quot;: 18,</div><div class="line">  &quot;school&quot;: &quot;华东交通大学111&quot;,</div><div class="line">  &quot;department&quot;: &quot;计算机科学&quot;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h2 id="为Spring-配置多个子配置文件-平行关系"><a href="#为Spring-配置多个子配置文件-平行关系" class="headerlink" title="为Spring 配置多个子配置文件-平行关系"></a>为Spring 配置多个子配置文件-平行关系</h2><blockquote>
<p>多个配置文件，加载的时候加载多个就行</p>
</blockquote>
<p><strong>配置文件1</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line">&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;</div><div class="line">       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</div><div class="line">       xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&quot;&gt;</div><div class="line">&lt;bean id=&quot;student&quot; class=&quot;Part03.ManyChildXmlFileParallel.Student&quot;&gt;</div><div class="line">    &lt;property name=&quot;name&quot; value=&quot;File1&quot;/&gt;</div><div class="line">    &lt;property name=&quot;age&quot; value=&quot;18&quot;/&gt;</div><div class="line">    &lt;property name=&quot;school&quot; value=&quot;华东交通大学&quot;/&gt;</div><div class="line">    &lt;property name=&quot;department&quot; value=&quot;软件&quot;/&gt;</div><div class="line">&lt;/bean&gt;</div><div class="line">&lt;/beans&gt;</div></pre></td></tr></table></figure></p>
<p><strong>配置文件2</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line">&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;</div><div class="line">       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</div><div class="line">       xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&quot;&gt;</div><div class="line">    &lt;bean id=&quot;teacher&quot; class=&quot;Part03.ManyChildXmlFileParallel.Teacher&quot;&gt;</div><div class="line">        &lt;property name=&quot;name&quot; value=&quot;File2&quot;/&gt;</div><div class="line">        &lt;property name=&quot;wordAge&quot; value=&quot;28&quot;/&gt;</div><div class="line">        &lt;property name=&quot;department&quot; value=&quot;计算机&quot;/&gt;</div><div class="line">        &lt;property name=&quot;school&quot; value=&quot;Ecjjtu&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">&lt;/beans&gt;</div></pre></td></tr></table></figure></p>
<p><strong>测试</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"> /**</div><div class="line"> * 为Spring配置多个配置文件-平行关系</div><div class="line"> */</div><div class="line">@Test</div><div class="line">fun test4ManyChildXmlFile() &#123;</div><div class="line">         //使用通配符*</div><div class="line">    //val classPathXmlApplicationContext = ClassPathXmlApplicationContext(&quot;applicationContextManyChildXmlFile*&quot;)</div><div class="line">    val classPathXmlApplicationContext = ClassPathXmlApplicationContext(&quot;applicationContextManyChildXmlFile1.xml&quot;, &quot;applicationContextManyChildXmlFile2.xml&quot;)</div><div class="line">    val student = classPathXmlApplicationContext.getBean(&quot;student&quot;) as Part03.ManyChildXmlFileParallel.Student</div><div class="line">    println(GsonBuilder().serializeNulls().setPrettyPrinting().create().toJson(student))</div><div class="line"></div><div class="line">    val teacher = classPathXmlApplicationContext.getBean(&quot;teacher&quot;) as Part03.ManyChildXmlFileParallel.Teacher</div><div class="line">    println(GsonBuilder().serializeNulls().setPrettyPrinting().create().toJson(teacher))</div><div class="line"></div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><strong>结果</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">&#123;</div><div class="line">  &quot;name&quot;: &quot;File1&quot;,</div><div class="line">  &quot;age&quot;: 18,</div><div class="line">  &quot;school&quot;: &quot;华东交通大学&quot;,</div><div class="line">  &quot;department&quot;: &quot;软件&quot;</div><div class="line">&#125;</div><div class="line">&#123;</div><div class="line">  &quot;name&quot;: &quot;File2&quot;,</div><div class="line">  &quot;wordAge&quot;: 28,</div><div class="line">  &quot;school&quot;: &quot;Ecjjtu&quot;,</div><div class="line">  &quot;department&quot;: &quot;计算机&quot;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h2 id="为Spring配置多个子配置文件-包含关系"><a href="#为Spring配置多个子配置文件-包含关系" class="headerlink" title="为Spring配置多个子配置文件-包含关系"></a>为Spring配置多个子配置文件-包含关系</h2><blockquote>
<p>在主配置中使用<import>将子配置文件导入到主配置文件中，所以程序只需要加载主配置文件。<br><strong>主配置文件</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line">&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;</div><div class="line">       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</div><div class="line">       xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&quot;&gt;</div><div class="line">    &lt;!--导入子配置文件--&gt;</div><div class="line">    &lt;!--&lt;import resource=&quot;applicationContextManyChildXmlFile1.xml&quot;/&gt;--&gt;</div><div class="line">    &lt;!--&lt;import resource=&quot;applicationContextManyChildXmlFile2.xml&quot;/&gt;--&gt;</div><div class="line">    &lt;!--使用通配符--&gt;</div><div class="line">    &lt;import resource=&quot;applicationContextManyChildXmlFile*.xml&quot;/&gt;</div><div class="line">&lt;/beans&gt;</div></pre></td></tr></table></figure></import></p>
</blockquote>

    </div>
    <p class="post-meta">
        <span class="post-cat">分类：
            <a class="cat-link" href="/coder957/categories/后端/">后端</a>|<a class="cat-link" href="/coder957/categories/后端/Java/">Java</a>
        </span>
        <span class="post-tags">
            标签：
            
    
        <a href="/coder957/tags/Java/" title="Java">Java</a> / 
    
        <a href="/coder957/tags/Spring/" title="Spring">Spring</a> / 
    
        <a href="/coder957/tags/kotlin/" title="kotlin">kotlin</a>
    

        </span>
    </p>
</article>
<!-- 分享按钮 -->

  <div class="article-share clearfix text-center">
    <div class="share-area">
      <span class="share-txt">分享到：</span>
      <a href="javascript: window.open('http://service.weibo.com/share/share.php?url=' + encodeURIComponent(location.href) + '&title=' + document.title + '&language=zh_cn');" class="share-icon weibo"></a>
      <a href="javascript: alert('请复制链接到微信并发送');" class="share-icon wechat"></a>
      <a href="javascript: window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + encodeURIComponent(location.href) + '&title=' + document.title);" class="share-icon qqzone"></a>
      <a href="javascript: window.open('http://connect.qq.com/widget/shareqq/index.html?url=' + encodeURIComponent(location.href) + '&desc=Jelon个人博客&title=' + document.title + '&callback=' + encodeURIComponent(location.href));" class="share-icon qq"></a>
      <a href="javascript: window.open('http://shuo.douban.com/!service/share?href=' + encodeURIComponent(location.href) + '&name=' + document.title + '&text=' + document.title);" class="share-icon douban"></a>
    </div>
  </div>


    <!-- 上一篇/下一篇 -->

<div class="article-nav clearfix">
    
    <span class="prev fl">
        上一篇<br >
        <a href="/coder957/2017/10/13/基于Annotation的DI-01/">
            
                基于Annotation的DI-01
            
        </a>
    </span>
    

    
    <span class="next fr">
        下一篇<br >
        <a href="/coder957/2017/10/12/进程和线程/">
            
                进程和线程
            
        </a>
    </span>
    
</div>

        <!-- 文章评论 -->
        
  <script src="/coder957/js/comment.js"></script>
  <div id="comments" class="comment">
    <!--
    <div class="sign-bar">
      GitHub 已登录!
      <span class="sign-link">登出</span>
    </div>
    <section class="box">
      <div class="com-avatar"><img src="/img/jelon.jpg" alt="avatar"></div>
      <div class="com-text">
        <div class="main">
          <textarea class="text-area-edited show" placeholder="欢迎评论！"></textarea>
          <div class="text-area-preview"></div>
        </div>
        <div class="switch">
          <div class="switch-item on">编辑</div>
          <div class="switch-item">预览</div>
        </div>
        <div class="button">提交</div>
      </div>
    </section>
    <section class="tips">注：评论支持 markdown 语法！</section>
    <section class="list-wrap">
      <ul class="list">
        <li>
          <div class="user-avatar">
            <a href="/">
              <img src="/img/jelon.jpg" alt="user-avatar">
            </a>
          </div>
          <div class="user-comment">
            <div class="user-comment-header">
              <span class="post-name">张德龙</span>
              <span class="post-time">2017年12月12日</span>
              <span class="like liked">已赞</span>
              <span class="like-num">2</span>
            </div>
            <div class="user-comment-body">333333</div>
          </div>
        </li>
        <li>
          <div class="user-avatar">
            <a href="/">
              <img src="/img/jelon.jpg" alt="user-avatar">
            </a>
          </div>
          <div class="user-comment">
            <div class="user-comment-header">
              <span class="post-name">刘德华</span>
              <span class="post-time">2017年12月12日</span>
              <span class="like">点赞</span>
              <span class="like-num">2</span>
            </div>
            <div class="user-comment-body">vvvvv</div>
          </div>
        </li>
      </ul>
      <div class="page-nav">
        <a href="javascript: void(0);" class="item">1</a>
        <a href="javascript: void(0);" class="item">2</a>
        <a href="javascript: void(0);" class="item current">3</a>
      </div>
    </section>
    -->
  </div>
  <script>
  JELON.Comment({
    container: 'comments',
    label: '基于XMl的DI-03' || '2017/10/12/基于XMl的DI-03/',
    owner: 'FutaoSmile',
    repo: 'blog_comments',
    clientId: '149ec394071cfd7f0f47',
    clientSecret: 'd1c988f53efa3f0f8651799f8212cc8e2cab24b9'
  });
  </script>


            </div>

        </section>
        <!-- 侧栏部分 -->
<aside class="sidebar">
    <section class="widget">
        <h3 class="widget-hd"><strong>文章分类</strong></h3>
        <!-- 文章分类 -->
<ul class="widget-bd">
    
    <li>
        <a href="/coder957/categories/后端/">后端</a>
        <span class="badge">(5)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/Java/">Java</a>
        <span class="badge">(8)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/Web技术/">Web技术</a>
        <span class="badge">(3)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/后端/Java/">Java</a>
        <span class="badge">(5)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/GIt/">GIt</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/Java/Spring/">Spring</a>
        <span class="badge">(3)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/Java/学习/">学习</a>
        <span class="badge">(5)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/Web技术/Java/">Java</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/Web技术/Kotlin/">Kotlin</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/GIt/Web技术/">Web技术</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/学习/">学习</a>
        <span class="badge">(1)</span>
    </li>
    
</ul>
    </section>

    
    <section class="widget">
        <h3 class="widget-hd"><strong>热门标签</strong></h3>
        <!-- 文章标签 -->
<div class="widget-bd tag-wrap">
  
    <a class="tag-item" href="/coder957/tags/Java/" title="Java">Java (12)</a>
  
    <a class="tag-item" href="/coder957/tags/Spring/" title="Spring">Spring (9)</a>
  
    <a class="tag-item" href="/coder957/tags/kotlin/" title="kotlin">kotlin (7)</a>
  
    <a class="tag-item" href="/coder957/tags/Maven/" title="Maven">Maven (2)</a>
  
    <a class="tag-item" href="/coder957/tags/Hibernate/" title="Hibernate">Hibernate (2)</a>
  
    <a class="tag-item" href="/coder957/tags/kotlin-小知识/" title="kotlin 小知识">kotlin 小知识 (1)</a>
  
    <a class="tag-item" href="/coder957/tags/Kotlin/" title="Kotlin">Kotlin (1)</a>
  
    <a class="tag-item" href="/coder957/tags/Json/" title="Json">Json (1)</a>
  
    <a class="tag-item" href="/coder957/tags/热点文章/" title="热点文章">热点文章 (1)</a>
  
    <a class="tag-item" href="/coder957/tags/博主推荐/" title="博主推荐">博主推荐 (1)</a>
  
    <a class="tag-item" href="/coder957/tags/转载/" title="转载">转载 (1)</a>
  
    <a class="tag-item" href="/coder957/tags/资料/" title="资料">资料 (1)</a>
  
    <a class="tag-item" href="/coder957/tags/Ajax/" title="Ajax">Ajax (1)</a>
  
</div>
    </section>
    

    

    
    <!-- 友情链接 -->
    <section class="widget">
        <h3 class="widget-hd"><strong>友情链接</strong></h3>
        <!-- 文章分类 -->
<ul class="widget-bd">
    
        <li>
            <a href="http://lsc95.github.io/" target="_blank" title="椿哥的狗窝">椿哥的狗窝</a>
        </li>
    
        <li>
            <a href="http://futaosmile.oschina.io/documents/" target="_blank" title="donot click me">Document</a>
        </li>
    
        <li>
            <a href="" target="_blank" title="虚位以待">loading...</a>
        </li>
    
</ul>
    </section>
    
</aside>
<!-- / 侧栏部分 -->
    </div>

    <!-- 博客底部 -->
    <footer class="footer">
    &copy;
    
                2016-
                2017
                    

                        <a href="/coder957/">Loves You</a>
</footer>
<div class="back-to-top" id="JELON__backToTop" title="返回顶部">返回顶部</div>
    <!--博客js脚本 -->
    <!-- 这里放网站js脚本 -->
<script src="/coder957/js/main.js"></script>
</body>
</html>